//
//  XMChatFucView.m
//  XMJJ_zmy
//
//  Created by 丁浩 on 2025/7/7.
//

#import "XMChatFucView.h"
#import "XMChatImgSend.h"

@implementation XMChatFucView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self creatUI];
    }
    return self;
}

- (void)creatUI {
    NSArray *titleArr = @[@"照片", @"拍照", @"位置"];
    NSArray *imgArr = @[@"chat_photo_icon", @"chat_camera_icon", @"chat_position_icon"];
    for (int i = 0; i < 2; i ++) {
        UIButton *itemBtn = [UIButton buttonWithType:UIButtonTypeCustom font:KFontSize(13.0) frame:CGRectMake(KScaleWidth(5.0) + KScaleWidth(72.0)*i, KScaleWidth(5.0), KScaleWidth(72.0), KScaleWidth(84.0)) title:titleArr[i] titleColor:kColorHEX(0x676364) image:imgArr[i]];
        [itemBtn layoutButtonWithEdgeInsetsStyle:CSButtonEdgeInsetsStyleTop ImageTitleSpace:KScaleWidth(10.0)];
        [itemBtn addTarget:self action:@selector(itemSelectAction:) forControlEvents:UIControlEventTouchUpInside];
        itemBtn.tag = 15000 + i;
        [self addSubview:itemBtn];
    }
}

//功能选择
- (void)itemSelectAction:(UIButton *)button {
    switch (button.tag - 15000) {
        case 0: {
            [[XMChatImgSend shareInstance] _selectPhotoWithPresentVC:(XMBaseViewController *)self.viewController];
            XMWeakSelf;
            [XMChatImgSend shareInstance].imgSelectBlock = ^(NSString * _Nonnull pathStr) {
                weakSelf.imgSendBlock ? weakSelf.imgSendBlock(pathStr) :nil;
            };
        }
            break;
        case 1: {
            
        }
            break;
            
        default:
            break;
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
